/**
 * Utopia Inc.
 *
 * @Copyright (c) 2013-2014  All rights reserved.
 */
package com.yiren.dbaa.view.toast;

import android.app.Activity;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.yiren.backstage.player.api.PlayerApi;
import com.yiren.dbaa.R;

/**
 * 消息助手类
 *
 * @author peng.zhao
 * @Date Mar 17, 2014 8:45:09 PM
 */
public class MessageBox {

    private static View toastRoot;
    private static Toast toastStart;
    private static TextView message;

    public static void show(Context context, CharSequence cs) {
        if (toastRoot == null) {
            toastRoot = ((Activity) context).getLayoutInflater().inflate(R.layout.general_toast, null);
            message = (TextView) toastRoot.findViewById(R.id.message);
        }
        if (null == toastStart) {
            toastStart = new Toast(context);
            toastStart.setGravity(Gravity.BOTTOM, 0, 10);
            toastStart.setDuration(Toast.LENGTH_SHORT);
        }
        message.setText(cs);
        toastStart.setView(toastRoot);
        toastStart.show();
    }

    public static void MessageAndVoiceModel(Context context, String content) {
        MessageBox.show(context, content);
        PlayerApi.playTipsVoice(context, content, null);
    }

    public static void VoiceModel(Context context, String content) {
        PlayerApi.playTipsVoice(context, content, null);
    }

}